<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <div style="border: 1px solid red;">
            姓: <input type="text" v-model="firstNum"><br/>
            名: <input type="text" v-model="endNum"><br/>
            姓名:{{firstNo}}
        </div>
        <div style="border: 1px solid red">
            <p>setter和getter</p>
            姓名：<input type="text" v-model="firstMo" /><br>
            <h1>{{firstMo}}</h1>
        </div>
    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.js"></script>
    <script type="text/javascript">
    var vm = new Vue({
        el:'#app',
        data:{
            firstNum:'',
            endNum:''
        },
        computed:{
            firstNo(){
                return this.firstNum + '-' + this.endNum;
            },
            firstMo:{
                get(){
                    return this.firstNum + ' ' + this.endNum;
                },
                set(v){
                    //v是input输入的值
                    console.log(v);
                    var name = v.split(' ');
                    console.log(name);
                    this.firstNum = name[0];
                    this.endNum = name[1];
                }
            }
        }
    });
    </script>
</body>
</html>